// JavaScript Document
(function() {
	tinymce.create('tinymce.plugins.SPA_Video', {
        init : function(ed, url) {
            ed.addButton('spa_video', {
                title : 'Url',
                image : url +'/btn-video.png',
                onclick : function() {
					var url		= prompt("Enter the url for your video, can be inserted source from youtube", "");
					if (url != null && url != '') {
						var width	= prompt("Enter the width of video, can be blank, default is 400px", "");
						var height	= prompt("Enter the height of video, can be blank, default is 300px", "");
						if ((width != null && width != '') && (height != null && height != '')) {
							ed.execCommand('mceInsertContent', false, '[video id="'+ url +'" width="'+ width +'" height="'+ height +'"]');
						} else {
							ed.execCommand('mceInsertContent', false, '[video id="'+ url +'" width="400" height="300"]');
						}
					} 
                }
            });
        },
        createControl : function(n, cm) {
            return null;
        },
		getInfo : function() {
			return {
				longname : "Video Shortcode",
				author : 'Cuong Phan',
				authorurl : 'http://izymedia.com/',
				infourl : 'http://izymedia.com/',
				version : "1.0"
			};
		}
    });
    tinymce.PluginManager.add('spa_video', tinymce.plugins.SPA_Video);
})();
